<?php

namespace App\Http\Requests;

use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Exceptions\HttpResponseException;

class sendGeneralRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'pull_id'=>'required',
            'post_id'=>'required',
            'push_id'=>'required',
            'status'=>'required',
            'read'=>'required',
            'msg'=>'required',
            'feedback'=>'required',
        ];
    }
    public function messages()
    {
        return[
          'pull_id.required'=>'pull_id 不能为空',
          'post_id.required'=>'post_id 不能为空',
          'push_id.required'=>'push_id 不能为空',
          'status.required'=>'status 不能为空',
          'read.required'=>'read 不能为空',
            'msg.required'=>'msg 不能为空',
            'feedback'=>'required 不能为空'
        ];
    }
    protected function failedValidation(Validator $validator)
    {
        throw (new HttpResponseException(response()->json([
            'code' => 100,
            'massages' => $validator->errors()->all()
        ], 422)));
    }
}
